/**
 *	流程模块接口文件：出入库详情
 *	开发者：雨中磐石
 *	地址：www.rockoa.com
 *	日期：2023-07-19
 */

package com.framework.Module.jxc.jxcgoods;





import com.framerock.baselib.Rock;
import com.framework.Flow.FlowListener;


import java.util.Map;


public class FlowListenerjxcgoods extends FlowListener {



    @Override
    public Boolean onModejs() {
        return true;
    }


    @Override
    public Map<String, String> onSavebefore(Map<String, String> da, String mid, Boolean isadd) {
        int kind = Rock.getMapint(da, "kind");
        Map<String, String> map = Rock.getMap();
        String type = "0";

        double count = Double.parseDouble(da.get("count"));
        if(count<0)count = 0 - count;
        if(kind>=20){
            type  = "1"; //出库
            count = 0 - count;
        }
        map.put("savefields", "type="+type+",count="+count+"");
        return map;
    }

    @Override
    public void onSaveafter(Map<String, String> da, String mid, Boolean isadd) {
        mFlow.let("jxcbase").action("reloadstock", da.get("sid"));
    }

    @Override
    public Map<String, String> onDatabefore() {
        String where = "";
        String dt = mRequest.get("dt");
        if(!Rock.isEmpt(dt))where = "`dt` <= '"+dt+"'";
        return Rock.getMap(new String[]{
                "where", where
        });
    }
}
